<?php
/**
 * sdPHP
 * @author     码农<8044023@qq.com>
 * @copyright  sdPHP
 * @license    https://gitee.com/cq8044023/sdphp
 */
namespace sdphp\lib\CoreBase;
use sdphp;
use sdphp\lib\Pack;
class PortManagr{
    const SOCK_TCP = 10;
    const SOCK_WS  = 11;
    protected $packs = [];
    protected $routes = [];
    public $portConfig;
    
    public static function setServer($pack_tool){  
        $swoole_config=array(
             'daemonize'=> sdphp\lib\Start::$daemonize
        );
        $swoole_config=array_merge($swoole_config,(new Pack())->start($pack_tool)->getProbufSet());
        return $swoole_config;
    }
    public function __construct($config){
        $this->setPortConfig($config);
    }
    public function setPortConfig($config){
        foreach ($config["Ports"] AS $v){
            $this->portConfig[$v["socket_type"]]=$v;
        }
    }
    public function getPortConfig($port){
        return $this->portConfig[$port];   
    }
}